var QQMapWX = require('../libs/qqmap-wx-jssdk1.2.js');
var qqmapsdk = new QQMapWX({
  key: 'IM6BZ-HZORR-TRQW6-WUC5W-SDAWE-W4F5Q' // 必填
});

Page({
  data: {
    showModal: false,
  },
  onLoad: function (options) {
    wx.getLocation({
      success: function (res) {
        console.log(res)
        console.log("纬度：" + res.latitude, "经度" + res.longitude)
          


        qqmapsdk.calculateDistance({
          mode: 'straight',//可选值：'driving'（驾车）、'walking'（步行 默认），'straight'（直线） 
          from: {
            latitude: res.latitude,
            longitude: res.longitude

            //东方路8号
            // latitude: 31.24323,
            // longitude: 121.51883
          },
          to: [{
            // latitude: 31.24323,
            // ongitude: 121.51883

            //浦东大道
            latitude: 31.240097,
            longitude: 121.519496
          }],
          success: function (res, data) {
            //距离
            var distance = res.result.elements['0'].distance;
            console.info(distance);
          },
          fail: function (error) {
            console.error(error);
          },
          complete: function (res) {
            console.log(res);
          }
        })

      

        qqmapsdk.geocoder({//地址解析
          address:"上海市浦东新区世纪大道2001号",
           success: function (res) {
            console.log(333)
            console.log(res)

          },
        })


        qqmapsdk.reverseGeocoder({//经纬度解析
          location: {
            latitude: res.latitude,
            longitude: res.longitude
          },
          success: function (res) {
            console.log(111)
            console.log(res)
          
          },
          fail: function (res) {
            //console.log(res);
          },
          complete: function (res) {
            //console.log(res);
          }
        })







      },
    })

     






















   
  }
})